//package com.liang.blog.utils;
//
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Component;
//import org.springframework.web.multipart.MultipartFile;
//
//import java.io.IOException;
//import java.nio.file.Files;
//import java.nio.file.Path;
//import java.nio.file.Paths;
//import java.util.UUID;
//
//@Component
//public class FileUploadUtil {
//    @Value("${file.upload-dir}")
//    private String uploadDir;
//
//    public String uploadFile(MultipartFile file) throws IOException {
//        // 创建存储目录（如果不存在）
//        Path uploadPath = Paths.get(uploadDir);
//        if (!Files.exists(uploadPath)) {
//            Files.createDirectories(uploadPath);
//        }
//
//        // 生成唯一文件名
//        String originalFilename = file.getOriginalFilename();
//        String fileExtension = originalFilename.substring(originalFilename.lastIndexOf("."));
//        String uniqueFileName = UUID.randomUUID().toString() + fileExtension;
//
//        // 保存文件
//        Path filePath = uploadPath.resolve(uniqueFileName);
//        Files.copy(file.getInputStream(), filePath);
//        return uniqueFileName;
//    }
//
////    public String downloadFile()
//}
